/**
 * 
 */
package uniandes.dermatologia.training;

import java.util.ArrayList;
import java.util.Date;

import uniandes.dermatologia.training.pojos.Question;

/**
 * @author Julio
 *
 */
public class TestLogic 
{
	private ArrayList<CaseLogic> caseLogics;
	
	private int id;
	
	private String name;
	
	private String description;
	
	private boolean withCases;
	
	private ArrayList<Question> questions;
	
	private double initial_range;
	
	private double final_range;
	
	private Date start_date;
	
	private Date end_date;
	
	private long seconds;
	
	private boolean answered;
	
	public TestLogic(int id, String name, String description, boolean withCases)
	{
		this.id = id;
		
		this.name = name;
		
		this.description = description;
		
		this.withCases = withCases;
		
		this.seconds = 0;
		
	}
	

	/**
	 * @return the withCases
	 */
	public boolean isWithCases() {
		return withCases;
	}

	/**
	 * @param withCases the withCases to set
	 */
	public void setWithCases(boolean withCases) {
		this.withCases = withCases;
	}

	/**
	 * @return the caseLogics
	 */
	public ArrayList<CaseLogic> getCaseLogics() {
		return caseLogics;
	}

	/**
	 * @param caseLogics the caseLogics to set
	 */
	public void setCaseLogics(ArrayList<CaseLogic> caseLogics) {
		this.caseLogics = caseLogics;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * @return the questions
	 */
	public ArrayList<Question> getQuestions() {
		return questions;
	}

	/**
	 * @param questions the questions to set
	 */
	public void setQuestions(ArrayList<Question> questions) {
		this.questions = questions;
	}

	/**
	 * @return the id
	 */
	public int getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(int id) {
		this.id = id;
	}

	/**
	 * @return the initial_range
	 */
	public double getInitial_range() {
		return initial_range;
	}

	/**
	 * @param initial_range the initial_range to set
	 */
	public void setInitial_range(double initial_range) {
		this.initial_range = initial_range;
	}

	/**
	 * @return the final_range
	 */
	public double getFinal_range() {
		return final_range;
	}

	/**
	 * @param final_range the final_range to set
	 */
	public void setFinal_range(double final_range) {
		this.final_range = final_range;
	}

	/**
	 * @return the start_date
	 */
	public Date getStart_date() {
		return start_date;
	}

	/**
	 * @param start_date the start_date to set
	 */
	public void setStart_date(Date start_date) {
		this.start_date = start_date;
	}

	/**
	 * @return the end_date
	 */
	public Date getEnd_date() {
		return end_date;
	}

	/**
	 * @param end_date the end_date to set
	 */
	public void setEnd_date(Date end_date) {
		this.end_date = end_date;
	}

	/**
	 * @return the seconds
	 */
	public long getSeconds() {
		return seconds;
	}

	/**
	 * @param seconds the seconds to set
	 */
	public void setSeconds(long duration) {
		this.seconds = duration;
	}
	
	/**
	 * Validates if the test can be answered by the student. A test can be
	 * answered only if the current date is within the starting and ending
	 * date defined by the teacher.
	 * @return <b><i>True</i></b> if the test can be answered and <b><i>False</i></b>
	 * on the contrary.
	 */
	public boolean isAccessible()
	{
		Date now = new Date();
		return now.after(start_date) && now.before(end_date);
	}

	/**
	 * @return the answered
	 */
	public boolean isAnswered() {
		return answered;
	}

	/**
	 * @param answered the answered to set
	 */
	public void setAnswered(boolean answered) {
		this.answered = answered;
	}
	
	
	
}
